package test;

import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerCollection;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.webapp.WebAppContext;

public class ExampleServer {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Server server = new Server();
        ServerConnector connector = new ServerConnector(server);
        connector.setPort(8080);
        server.setConnectors(new Connector[] { connector });
        ServletContextHandler context = new ServletContextHandler();
        context.setContextPath("/");
        context.addServlet(HelloWord.class, "/helloWord");
        context.addServlet(UploadHandlerServlet.class, "/UploadHandlerServlet");
        /*WebAppContext webapp = new WebAppContext();  
        webapp.setWar("E:/jetty/my-base/webapps/Test.war");
        webapp.setContextPath("/Test");
        String welcomeFile = "index.jsp,test.html";
        webapp.setWelcomeFiles(welcomeFile.split(","));*/
        HandlerCollection handlers = new HandlerCollection();
        handlers.setHandlers(new Handler[] { context, new DefaultHandler() });
        server.setHandler(handlers);
        try {
			server.start();
			server.join();
		} catch (Exception e) {
			e.printStackTrace();
		}
        
	}

}
